package homework01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
import java.util.WeakHashMap;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        while ( true){
            System.out.print("请输入文件名:");
            String fileName = scan.next();
            if(fileName.equals("退出")){
                System.out.println("程序结束");
                break;
            }else {
                FileInputStream fin = new FileInputStream(fileName);
                FileOutputStream fos = new FileOutputStream("cp_" + fileName);
                byte[] bytes = new byte[1024 * 10];
                int d;
                while ((d = fin.read(bytes)) != -1) {
                    fos.write(bytes, 0, d);
                }
                System.out.println("复制完成");
                fos.close();
                fin.close();
            }

        }

    }
}
